var attachmentFileUrls = []; 
var id = window.location.href.split("&")[0].split("=")[1];

function sendAttachments(listname)
{
getAttachmentFiles(listname,id);
}

 
function getAttachmentFiles(listName,listItemId) 
{
   $().SPServices({
        operation: "GetAttachmentCollection",
        async: false,
        listName: listName,
        ID: listItemId,
        completefunc: function(xData, Status) {
            $(xData.responseXML).find("Attachment").each(function() {
               var url = $(this).text();
               attachmentFileUrls.push(url);
            });
            getOutlook();
            }
   });
}

function getOutlook() {
    var outlook;
    var otem;
    var modalDialog;
    try {
        modalDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose("Sending", "Please wait...", 300, 400);
        outlook = new ActiveXObject('Outlook.Application');
        otem = outlook.CreateItem(0);
        if (attachmentFileUrls != null) {
        for(var i=0;i<attachmentFileUrls.length;i++)
        {
            otem.Attachments.Add(attachmentFileUrls[i]);
            attachmentFileUrls[i] = null;
        }
        attachmentFileUrls = [];
            otem.Subject = "Attachments";
        }
        otem.Display();
        otem.GetInspector.WindowState = 2;
    } catch (err) {
        alert("Security Error. Check your ActiveX security settings.");
    } finally {
        otem = null;
        outlook = null;
        if (notification != null) SP.UI.Notify.removeNotification(notification);
        SP.UI.ModalDialog.commonModalDialogClose(1, '0');
    }
}

